<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理系统</title>
<jsp:include page="../../header.jsp"></jsp:include>
<jsp:include page="../../title.jsp"></jsp:include>
</head>
<style>
*{
	font-size:12px;
}
body {
    font-family:helvetica,tahoma,verdana,sans-serif;
    font-size:13px;
}
html,body {
	width: 100%;
	height: 100%;
	margin: 0 auto;
	/* background:#3A6EA5; */
	overflow: hidden;
}
input{
	border:1px solid #9ABAE9;
}
</style>
<script type="text/javascript">var contextPath="${pageContext.request.contextPath}";</script>
</head>
<body>
<div style="width:100%;height:100%;" class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:65px;background:url('${pageContext.request.contextPath}/images/banner.png');">
		<!-- 上内容 -->
						
						<div style="width:100%;height:100%;float:right;">
  			  		    		<table width="100%" height="100%">
  			  		    			<tr>
  			  		    			    <td>
  			  		    			    	<div style="width:320px;height:58px;background:url(${pageContext.request.contextPath}/images/logo1.png);"></div>
  			  		    			    </td>
  			  		    				<td align="center" valign="middle">
  			  		    					<div style="float:right;">
			  			  		    				<span>
														<span>${sysUser.sysUserName}</span>，欢迎你！
													</span>
													<span>
														<span class="user-name"><a href="javascript:void(0)" id="mb1" class="easyui-menubutton" menu="#mm1" iconCls="icon90">皮肤更换</a></span>					                                                                                         			
													</span>
													<span>
														<a href="javascript:void(0)"  class="easyui-linkbutton"   data-options="iconCls:'icon283',plain:true" onclick="outLogin()">退出系统</a>														
													</span>
			  			  		    		</div>	  		
  			  		    				</td>
  			  		    			</tr>
  			  		    	</table>    	 			  		    	
  			  		    	</div>
		<!-- 上内容 -->
	</div>
	<div data-options="region:'west',split:true,title:'系统管理',collapsible:false" style="width:200px;padding:5px;">
		<!-- 左内容 -->				  
								<ul id="index_tree" class="ztree"></ul>						
		<!-- 左内容 -->
	</div>
	<div data-options="region:'south',border:false" style="height:20px;background:#E6EEF8;">
		<!-- 下内容 -->
  			  				  		<marquee> 勤智数码有限公司--版权所有,违者必究 2013-01-01</marquee>	  	 
		<!-- 下内容 -->
	</div>
	<div data-options="region:'center'" border="0">
		<!-- 中内容 -->
			<div id="tabsMain" class="easyui-tabs"  style="width:100%;height:100%;"  data-options="fit:true">
						<div title="系统介绍" style="padding:10px" closable="true" iconCls="icon101">
							<p style="font-size:14px">IDC综合运营系统介绍</p>
							<ul>
								<li>系统管理.</li>	
								<li>流程管理.</li>		
								<li>资源管理.</li>								 
							</ul>
						</div>	
			</div>		
		<!-- 中内容 -->
	</div>
</div>
<div style="display: none;">
<div id="mm1" style="width:150px;">
								<div iconCls="icon30" onclick="chooseThem(1)">default</div>
								<div iconCls="icon31" onclick="chooseThem(2)">gray</div>
								<div iconCls="icon32" onclick="chooseThem(3)">metro</div>
								<div iconCls="icon33" onclick="chooseThem(4)">bootstrap</div>
								<div iconCls="icon34" onclick="chooseThem(5)">black</div>
								
</div>
<div style="display: none;">
  <div id="TablerightKey" class="easyui-menu" style="width:140px;">
		<div iconCls="icon14" onclick="closeTabs(1)">关闭当前选中项目</div>
		<div iconCls="icon12" onclick="closeTabs(2)">除选中项全部关闭</div>
		<div iconCls="icon11" onclick="closeTabs(3)">关闭选中前面打开</div>
		<div iconCls="icon13" onclick="closeTabs(4)">关闭选中后面打开</div>
	</div>
</div>
</body>
<script type="text/javascript">
//页面初始化
function initPage(){

	$(document).ready(function(){

		var setting = {
				data: {
					simpleData: {
						enable: true
					}
				},
				callback: {
					onClick: zTreeOnClick
				}	
		};
		var zNodes =eval('(${listZtree})');
		
		$.fn.zTree.init($("#index_tree"), setting, zNodes);
	});
}
//ztree点击事件
function zTreeOnClick(event, treeId, treeNode) {
			 if(treeNode.power_url==""){
				   return;
		     }
		     //如果当前是一个内部权限还是外部权限
		     //例如进来的就是 http:www.baidu.com
			var b =$('#tabsMain').tabs('exists',treeNode.name);
			if(b){
				$('#tabsMain').tabs('select',treeNode.name);
				return;
			}
			   $("#tabsMain").tabs("add",{
				   title : treeNode.name,
					closable : true,	
					cache:false,
					urlType:treeNode.urlType,
					power_url:treeNode.power_url,
					power_it:treeNode.power_it,
					icon : treeNode.iconSkin
				});	
};
//初始化所有tabs
function initTabs(){
	$("#tabsMain").tabs({
		onSelect:function(title,index){
		 	$('#main_tabs_content').html("");
		    var main_tabs_content=$('#main_tabs_content');		   
			var ta1b =$("#tabsMain").tabs("getTab",title);
			//当前路径
			var url=ta1b.panel('options').power_url;
			//是div，还是iframe
			var power_it=ta1b.panel('options').power_it;
			//是内部的还是外部的
			var urlType=ta1b.panel('options').urlType;

			//alert("路径是==="+url+"=载入类型=="+power_it+"===权限类型=="+urlType);
		
			//如果是外部的
			if(urlType=="1"){
				 $('#tabsMain').tabs('update',{
						tab : ta1b,
						options :
						{
						    content:'<iframe  scrolling="no" name="contentIF" width="100%" height="100%" id="'+new Date()+'"   iframeName="'+title+'" src="'+url+'" frameborder="0"  scrolling="no" marginwidth="0" marginheight="0"></iframe>'			   		   					
						}
				 });		
			}
			//如果是内部的
			if(urlType=="0"){
				//如果是内容的，也是一个iframe的
				if(power_it=="0"){
					 $('#tabsMain').tabs('update',{
							tab : ta1b,
							options :
							{
							    content:'<iframe  scrolling="no" name="contentIF" width="100%" height="100%" id="'+new Date()+'"   iframeName="'+title+'" src="'+url+'" frameborder="0"  scrolling="no" marginwidth="0" marginheight="0"></iframe>'			   		   					
							}
					 });				
				}
				//如果是内容的，是一个div
				 var main_tabs_content;
					if($('#main_tabs_content').length==0){
					
						 main_tabs_content= $('<div id="main_tabs_content" style="width:100%;height:100%;margin:0 auto;"></div>');
	
					}else{
						 main_tabs_content=$('#main_tabs_content');
				   }
				if(power_it=="1"){
					 $('#tabsMain').tabs('update',{
							tab : ta1b,
							options :
							{
							   content:main_tabs_content.load(url)
							}
					 });	
					
				}
			}
		}
	});
}

//退出系统		
function outLogin(){
	$.messager.confirm('提示','你确定要退出系统吗？', function(r){		
		if(r){
			$.ajax({
				   type: "POST",
				   url: "${pageContext.request.contextPath}/sys/sysUserAction!outLogin.action",
				   dataType:'text',
				   success: function(msg){
					   window.open("${pageContext.request.contextPath}","_self");
				   }
				});			
		}
	});
}
//初始化右键菜单
function initTabsMenu(){
	//关闭右键
	$(document).bind('contextmenu',function(e){
				return false;
	});
	//给tabs增加右键
	 $('#tabsMain').tabs({
	    	onContextMenu:function(e,title){
		 		$('#tabsMain').tabs("select",title);
				$('#TablerightKey').menu('show',{
									left:e.pageX,
									top:e.pageY
								});
	    		}
	 });
}
//tabs右键关闭事件
function closeTabs(c){
	//关闭当前选项
	if(c==1){
		var title =$('#tabsMain').tabs("getSelected").panel("options").title;
		$('#tabsMain').tabs("close",title);
	}
	//除此全部关闭
	if(c==2){
		var  tab =$('#tabsMain').tabs("getSelected");
		//var tabselectIndex=$('#tabsMain').tabs("getTabIndex",tab);
		var tabselectTitle=tab.panel("options").title;

		var titleArray = new Array();
		for(var i=0;i<$('#tabsMain').tabs("tabs").length;i++){
			var title=$('#tabsMain').tabs("tabs")[i].panel("options").title;
			titleArray.push(title);
		}
		for(var i =0;i<titleArray.length;i++){
			if(titleArray[i]!=tabselectTitle){
				$('#tabsMain').tabs("close",titleArray[i]);
			}
		}
	}
	//关闭前面打开
	if(c==3){
		var  tab =$('#tabsMain').tabs("getSelected");	
		var tabselectIndex=$('#tabsMain').tabs("getTabIndex",tab);
		var titleArray = new Array();
		for(var i=0;i<$('#tabsMain').tabs("tabs").length;i++){
			var index=$('#tabsMain').tabs("getTabIndex",$('#tabsMain').tabs("tabs")[i]);
			var title=$('#tabsMain').tabs("tabs")[i].panel("options").title;
			if(i<tabselectIndex){
				titleArray.push(title);
			}
		}
		for(var i =0;i<titleArray.length;i++){
			$('#tabsMain').tabs("close",titleArray[i]);
		}
		
	}
	//关闭后面打开
	if(c==4){
		var  tab =$('#tabsMain').tabs("getSelected");	
		var tabselectIndex=$('#tabsMain').tabs("getTabIndex",tab);
		var titleArray = new Array();
		for(var i=0;i<$('#tabsMain').tabs("tabs").length;i++){
			var index=$('#tabsMain').tabs("getTabIndex",$('#tabsMain').tabs("tabs")[i]);
			var title=$('#tabsMain').tabs("tabs")[i].panel("options").title;
			if(i>tabselectIndex){
				titleArray.push(title);
			}
		}
		for(var i =0;i<titleArray.length;i++){
			$('#tabsMain').tabs("close",titleArray[i]);
		}
	}
}		
//换肤
function chooseThem(temp){
	delCookie("easyThem");
	if(temp==1){
		SetCookie("easyThem","default");
	}
	if(temp==2){
		SetCookie("easyThem","gray");	
	}
	if(temp==3){
		SetCookie("easyThem","metro");
	}
	if(temp==4){
		SetCookie("easyThem","bootstrap");
	}
	if(temp==5){
		SetCookie("easyThem","black");
	}
	location.reload();
} 
$(function(){
	initPage();
	//inItCookingTabs();
	initTabs();
	initTabsMenu();
});
</script>
</html>